package com.estar.assistsurvy.adapter;

import java.util.List;

import com.estar.assistsurvy.R;
import com.estar.assistsurvy.entity.ChargeVO;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ChargeListAdapter extends BaseAdapter {

	private List<ChargeVO> chargeList;
	private LayoutInflater inflater;
	
	public ChargeListAdapter(List<ChargeVO> chargeList, Context context) {
		super();
		this.chargeList = chargeList;
		inflater=LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return chargeList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return chargeList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder;
		if(convertView==null){
			convertView=inflater.inflate(R.layout.chargelist_item, null);
			holder=new ViewHolder();
			holder.task_icon=(ImageView) convertView.findViewById(R.id.task_icon);
			holder.task_name=(TextView) convertView.findViewById(R.id.task_name);
			holder.task_content=(TextView) convertView.findViewById(R.id.task_content);
			convertView.setTag(holder);
		}else{
			holder=(ViewHolder) convertView.getTag();
		}
		ChargeVO chargeVO=chargeList.get(position);
		holder.task_icon.setImageResource(R.drawable.icon_detail07);
		holder.task_name.setText(chargeVO.getName());
		holder.task_content.setText(chargeVO.getCharge());
		return convertView;
	}
	
	private class ViewHolder{
		private ImageView task_icon;
		private TextView task_name,task_content;
	}

}
